/*
 * RTSAI - Real-Time Strategy engine for AI research
 * Copyright(C) 2006 DIMAp-UFRN, licensed under LGPL
 *
 * Player header ( Player.h )
 */

#ifndef PLAYER_H_
#define PLAYER_H_

// INCLUDES -------------------------------------------------------------------
#include <string>

#include "Pool.h"
#include "Unit.h"
#include "Message.h"

// CLASS ----------------------------------------------------------------------
/*! This class implements a player for the game
 */
class Player : public MessageReceiver, public PoolElement
{
    // PUBLIC METHODS =========================================================
    public:
        // Constructor --------------------------------------------------------
        Player ( const string &n = "default",
                 const string &cn = "civilization" ): name ( n ),
                                                      civilization ( cn ),
                                                 units ( Pool < Unit > ( 10 ) )
             { /* Empty */ };

        // string -------------------------------------------------------------
        string get_name ();
        string get_civ_name ();

        // void ---------------------------------------------------------------
        void set_name ( const string& );
        void set_civ_name ( const string& );
        void update ( const float elapsed_time );

        // Unit related methods -----------------------------------------------
        Unit* create_unit ();
        const Pool< Unit >& get_units() const { return units; }
        int get_num_units ()  { return units.get_size(); }
        Unit& get_unit ( int id ) { return units[id]; }

        // Message related methods --------------------------------------------
        void add_message ( Message *msg );

        // PoolElement related methods ----------------------------------------
        void reset ();

        // Destructor ---------------------------------------------------------
        virtual ~Player ();

        bool operator== ( const Player &compared ) const {
            return this == &compared;
        }

    // ATTRIBUTES =============================================================
    private:
        /// A player name
        string name;

        /// A player civilization
        string civilization;

        /// Pool of units
        Pool < Unit > units;

}; // End of Player class

#endif // PLAYER_H_
